﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DbProfiler.DatabaseAccess.SchemaExtraction
{
    public class MsftSqlTypeMappingFactory
    {
        public static Type MapType(int sqlTypeNumber)
        {
            switch (sqlTypeNumber)
            {
                case 2:     // smallint
                    return typeof(System.Int16);

                case 3:     // int
                    return typeof(System.Int32);

                case 6:     // smallmoney
                    return typeof(System.Decimal);

                case 11:    // bit
                    return typeof(System.Boolean);

                case 17:    // tinyint
                    return typeof(System.Byte);
                
                case 72:    // uniqueidentifier
                    return typeof(System.Guid);

                case 128:   // varbinary(max)
                    throw new NotImplementedException("The type number '" + sqlTypeNumber.ToString() + "' is not currently implemented!");

                case 129:   // varchar
                    return typeof(System.String);

                case 130:   // nvarchar
                    return typeof(System.String);

                case 131:   // decimal
                    return typeof(System.Decimal);

                case 135:   // datetime
                    return typeof(System.DateTime);
                    
                default:
                    throw new NotImplementedException("The type number '" + sqlTypeNumber.ToString() + "' is not currently implemented!");
            }
        }
    }
}
